<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>设备场站管理</title>
	<meta name="decorator" content="ani"/>
	<script type="text/javascript">
		var validateForm;
		var $table; // 父页面table表格id
		var $topIndex;//弹出窗口的 index
		function doSubmit(table, index){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		 if($("#nums").val()!=""){
			if(parseInt($("#nums").val())>20){
                jp.error("列数配置最大20");
                return false;
			}
		 }
		   if(validateForm.form()){
			  $table = table;
			  $topIndex = index;
			  jp.loading();
			  $("#inputForm").submit();
			  return true;
		  }

		  return false;
		}

		$(document).ready(function() {
            if($("#localeId").val()!=""){
                $("#devTab").show();

                $.ajax({
                    type: "post",
                    url: '${ctx}/screen/show/localInfo?id='+$("#localeId").val(),
                    async: false,
                    dataType: "json",
                    success: function (data) {
						console.log(data);
                    }
				});

                $.ajax({
                    type: "post",
                    url: '${ctx}/screen/show/weatherInfo?id='+$("#localeId").val(),
                    async: false,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                    }
                });

            }
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					jp.post("${ctx}/locale/devStation/save",$('#inputForm').serialize(),function(data){
						if(data.success){
	                    	$table.bootstrapTable('refresh');
	                    	jp.success(data.msg);
	                    	jp.close($topIndex);//关闭dialog

	                    }else{
            	  			jp.error(data.msg);
	                    }
					})
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
		});
	</script>
</head>
<body class="bg-white">
		<form:form id="inputForm" modelAttribute="devStation" class="form-horizontal">
		<form:hidden path="id" id="localeId"/>
		<sys:message content="${message}"/>	
		<table class="table table-bordered">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>场站名称：</label></td>
					<td class="width-35">
						<form:input path="name" htmlEscape="false"    class="form-control required"/>
					</td>
					<td class="width-15 active"><label class="pull-right">所属部门：</label></td>
					<td class="width-35">
						<sys:treeselect id="office" name="office.id" value="${devStation.office.id}" labelName="office.name" labelValue="${devStation.office.name}"
							title="部门" url="/sys/office/treeData?type=2" cssClass="form-control " allowClear="true" notAllowSelectParent="true"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">基坑周边环境图：</label></td>
					<td class="width-35">
						<form:hidden id="picOne" path="picOne" htmlEscape="false" maxlength="200" class="form-control"/>
						<sys:ckfinder input="picOne" type="images" uploadPath="/locale/devStation" selectMultiple="true"/>
					</td>
					<td class="width-15 active"><label class="pull-right">水文地质剖面图：</label></td>
					<td class="width-35">
						<form:hidden id="picTwo" path="picTwo" htmlEscape="false" maxlength="200" class="form-control"/>
						<sys:ckfinder input="picTwo" type="images" uploadPath="/locale/devStation" selectMultiple="true"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">场站宽度：</label></td>
					<td class="width-35">
						<form:input path="width" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="pull-right">场站长度：</label></td>
					<td class="width-35">
						<form:input path="height" htmlEscape="false"    class="form-control  number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>A岸配置：</label></td>
					<td class="width-35">
						<form:select path="aConfig"  class="form-control m-b required">
							<form:option value="" label=""/>
							<form:option value="东岸" label="东岸"/>
							<form:option value="南岸" label="南岸"/>
							<form:option value="西岸" label="西岸"/>
							<form:option value="北岸" label="北岸"/>
						</form:select>
					</td>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>B岸配置：</label></td>
					<td class="width-35">
						<form:select path="bConfig"  class="form-control m-b required">
							<form:option value="" label=""/>
							<form:option value="东岸" label="东岸"/>
							<form:option value="南岸" label="南岸"/>
							<form:option value="西岸" label="西岸"/>
							<form:option value="北岸" label="北岸"/>
						</form:select>
					</td>
				</tr>
				<tr >
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>列数配置：</label></td>
					<td class="width-35">
						<form:input path="nums" htmlEscape="false"  id="nums" class="form-control  digits required"/>
					</td>

				</tr>
				<tr id="devTab" style="display: none">
					<td class="width-15 active"><label class="pull-right">关联设备：</label></td>
					<td class="width-35">
						<sys:gridselect url="${ctx}/device/device/data?devStation.id=-1" isMultiSelected="true"  id="dev" name="devIds" value="${device.id}" labelName="dev.code" labelValue="${device.code}"
										title="选择设备" cssClass="form-control " fieldLabels="设备" fieldKeys="code" searchLabels="设备" searchKeys="code" ></sys:gridselect>
					</td>

				</tr>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>